package com.chenqi.controller;

import com.chenqi.model.entity.Promotion;
import com.chenqi.service.PromotionService;
import com.chenqi.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description:
 * @program: ardaicommunity
 * @author: ChenQi
 * @create: 2021-03-2021/3/7-15-52
 */
@RestController
@RequestMapping("/api/v1/promotion")
public class PromotionController {

    @Autowired
    private PromotionService promotionService;

    /**
     * 获取所有推荐
     * @return
     */
    @GetMapping("/list")
    public JsonData list() {
        List<Promotion> allPromotions = promotionService.getAllPromotions();
        return allPromotions == null ? JsonData.BuildError("获取失败") : JsonData.BuildSuccess(allPromotions, "获取成功");
    }
}
